//
//  TSCardListTableViewCell.swift
//  TSProfitProject
//
//  Created by TMS on 2019/11/5.
//  Copyright © 2019 TMS. All rights reserved.
//

import UIKit
import HandyJSON

struct TSCardListModel : HandyJSON {
    
    var addtime : Int64 = 0
    var bankadress : String? = nil
    var bankname : String? = nil
    var bankusername : String? = nil
    var banknum : Int64 = 0
    var id : Int = -1
    var uid : Int = -1
}

class TSCardListTableViewCell: UITableViewCell {
    
    var bgView : UIView!
    var bankLabel : UILabel!
    var numLabel : UILabel!
    var model : TSCardListModel?

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        configViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    public func setupCell(model : TSCardListModel) {
        self.model = model
        bankLabel.text = model.bankname
        numLabel.text = "\(model.banknum)"
    }
    
    func configViews() {
        
        bgView = UIView.init()
        bgView.backgroundColor = UIColor.hexadecimalColor(hexadecimal: "#2C76FF")
        bgView.layer.cornerRadius = 5
        bgView.layer.masksToBounds = true
        self.contentView.addSubview(bgView)
        bgView.snp.makeConstraints { (make) in
            make.left.equalTo(12)
            make.right.equalTo(-12)
            make.top.equalToSuperview()
            make.height.equalTo(133)
        }
        
        bankLabel = UILabel.init()
//        bankLabel.text = "XX银行储蓄卡"
        bankLabel.textColor = WHITE_COLOR;
        bankLabel.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        bankLabel.adjustsFontSizeToFitWidth = true
        bankLabel.minimumScaleFactor = 0.6
        bgView.addSubview(bankLabel)
        bankLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20)
            make.right.equalTo(-20)
            make.top.equalToSuperview().offset(15)
        }
        
        numLabel = UILabel.init()
//        numLabel.text = "**** **** **** 3221"
        numLabel.textColor = WHITE_COLOR;
        numLabel.font = UIFont.systemFont(ofSize: 24, weight: .medium)
        bgView.addSubview(numLabel)
        numLabel.snp.makeConstraints { (make) in
            make.left.right.equalTo(bankLabel)
            make.centerY.equalToSuperview()
        }
    }

}
